"use strict";
cc._RF.push(module, 'd5641rdjP9IuogodYi2BVYN', 'CameraManager');
// script/game/CameraManager.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var GameData_1 = require("../libs/GameData");
var HelperMgr_1 = require("../libs/HelperMgr");
var GameManager_1 = require("./GameManager");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var CameraManager = /** @class */ (function (_super) {
    __extends(CameraManager, _super);
    function CameraManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.target = null;
        _this.isFollowing = false;
        return _this;
    }
    CameraManager_1 = CameraManager;
    // LIFE-CYCLE CALLBACKS:
    CameraManager.prototype.onLoad = function () {
        CameraManager_1.instance = this;
    };
    CameraManager.prototype.start = function () {
    };
    CameraManager.prototype.update = function (dt) {
        if (GameManager_1.default.instace.gameIsStart && !GameManager_1.default.instace.gameIsOver)
            if (this.target && GameData_1.default.instance.gameModel) {
                this.isFollowing = true;
                this.node.x = HelperMgr_1.default.lerp(this.node.x, this.target.x - cc.winSize.width / 2, 0.5);
                this.node.y = HelperMgr_1.default.lerp(this.node.y, this.target.y - cc.winSize.height / 2, 0.5);
            }
            else {
                this.isFollowing = false;
                this.node.setPosition(0, 0);
            }
    };
    var CameraManager_1;
    CameraManager.instance = null;
    CameraManager = CameraManager_1 = __decorate([
        ccclass
    ], CameraManager);
    return CameraManager;
}(cc.Component));
exports.default = CameraManager;

cc._RF.pop();